// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
    // API 调用都保持和云函数当前所在环境一致
    env: cloud.DYNAMIC_CURRENT_ENV
  })

// 云函数入口函数
exports.main = async (event, context) => {
    const db = cloud.database()
    //查询体重最大值
    const weightList = await db.collection('health_rdl')
        .where({
            openId: event.userInfo.openId,
            month: event.month,
        })
        .orderBy('month', 'asc')
        .get()
        .then(res => {
            console.error("查询本月体重列表返回", res)
            return res.data
        })
        .catch(res => {
            console.error("查询本月体重列表错误", res)
        })

    return {
        weightList: weightList
    }
}
